package HomeWork3_24;

import java.util.HashMap;
import java.util.Scanner;
public class HomeWork3_24_3 {
    public static void main(String[] args) {
        HashMap<String,Student>hash = new HashMap<String,Student>();
        System.out.println("已录入学生信息：");
        System.out.println("————————————————————————————————");
        System.out.println("| 学号 | 姓名  | 专业   |  成绩  |");
        System.out.println("————————————————————————————————");
        System.out.println("| 001  | 张三  | 计算机 | 100分  |");
//        System.out.println("————————————————————————————————");
        System.out.println("| 002  | 李四  | 美术   | 99分   |");
//        System.out.println("————————————————————————————————");
        System.out.println("| 003  | 王五  | 体育   | 98分   |");
        System.out.println("————————————————————————————————");
        System.out.println("输入学号查询信息（输入-1终止程序）");
        hash.put("001",new Student("张三","计算机",100));
        hash.put("002",new Student("李四","美术",99));
        hash.put("003",new Student("王五","体育",98));
        Scanner sc = new Scanner(System.in);
        String s;
        while(true){
            s = sc.nextLine();
            if(s.equals("-1"))
                break;
            if(hash.containsKey(s)) {
                Student stu = hash.get(s);
                System.out.println("学生信息：" + stu.name + ' ' + stu.major + ' ' + stu.grad);
            }
            else
                System.out.println("无该学生信息");
        }
    }
}

class Student{
    public String name;
    public String major;
    public int grad;

    public Student(String name, String major, int grad) {
        this.name = name;
        this.major = major;
        this.grad = grad;
    }
}